import json

def convert_repos():
    # 读取原始JSON文件
    with open('d:/code/JavaProject/TestExecutionPlatform/backend/src/main/resources/data/repos_sample.json', 'r', encoding='utf-8') as f:
        data = json.load(f)
    
    # 转换格式
    new_repos = []
    for repo in data['repositories']:
        new_repo = {
            "owner": "openharmony-tpc",
            "name": "openharmony_tpc_samples",
            "sub_dir": repo['name']
        }
        new_repos.append(new_repo)
    
    # 写入新的JSON文件
    with open('d:/code/JavaProject/TestExecutionPlatform/backend/src/main/resources/data/repos_sample_new.json', 'w', encoding='utf-8') as f:
        json.dump({"repositories": new_repos}, f, indent=4, ensure_ascii=False)

if __name__ == '__main__':
    convert_repos()